class LocalStore{
    constructor(){
        this.getConfig()
    }
    /**
     * 基础方法
     */
    config = {}
    configName = "_CONFIG_" 
    getConfig(){
        let c = localStorage.getItem(this.configName)
        if(c==null){
            this.config = {_INIT_:''}
            this.setConfig()
        }else{
            this.config = JSON.parse(c)
        }
        console.log(this.config)
        return this.config
    }
    setConfig(config = this.config){
        const c = JSON.stringify(config)
        this.config = c
        localStorage.setItem(this.configName,c)
    }
    getProp(key){
        try {          
            return this.getConfig()[key]
        } catch (error) {
            return ""
        }
    }
    setProp(key,value){
        this.getConfig()[key] = value
        this.setConfig()
    }
    /**
     * 
     */
}
class DirLocalStore extends LocalStore{
    constructor(){
        super()
    }
    dirName = "_DIR_"
    getDir(){
        let dir = this.getProp(this.dirName)
        if(dir) return dir
        return ""
    }
    setDir(dir){
        this.setProp(this.dirName,dir)
    }
}
const dls = new DirLocalStore()
export {
    LocalStore,
    DirLocalStore,
    dls
}